package com.vshining.cryptoki.jna.pkcs11t;


import com.sun.jna.NativeLong;
import com.sun.jna.Structure;

import java.util.Arrays;
import java.util.List;

/**
 * <pre>
 * CK_INFO provides general information about Cryptoki.  It is defined as follows:
 *
 *   typedef struct CK_INFO {
 *       CK_VERSION cryptokiVersion;
 *       CK_UTF8CHAR manufacturerID[32];
 *       CK_FLAGS flags;
 *       CK_UTF8CHAR libraryDescription[32];
 *       CK_VERSION libraryVersion;
 *   } CK_INFO;
 *
 * The fields of the structure have the following meanings:
 *
 *     cryptokiVersion        Cryptoki interface version number, for compatibility with
 *                            future revisions of this interface
 *
 *     manufacturerID         ID of the Cryptoki library manufacturer.
 *                            Must be padded with the blank character (‘ ‘).
 *                            Should not be null-terminated.
 *
 *     flags                  bit flags reserved for future versions.
 *                            Must be zero for this version
 *
 *     libraryDescription     character-string description of the library.
 *                            Must be padded with the blank character (‘ ‘).
 *                            Should not be null-terminated.
 *
 *     libraryVersion	      Cryptoki library version number
 *
 * For libraries written to this document, the value of cryptokiVersion should match the version
 * of this document; the value of libraryVersion is the version number of the library software itself.
 * </pre>
 *
 * @author Shining Wang <shiningwang@vshining.com>
 */
@SuppressWarnings("unused")
public class CK_INFO extends Structure {
    public CK_VERSION cryptokiVersion;
    public byte[] manufacturerID = new byte[32];
    public NativeLong flags;
    public byte[] libraryDescription = new byte[32];
    public CK_VERSION libraryVersion;

    @Override
    protected List getFieldOrder() {
        return Arrays.asList(
                "cryptokiVersion",
                "manufacturerID",
                "flags",
                "libraryDescription",
                "libraryVersion"
        );
    }
}
